﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Cmd.TypeConverters
{
    public class NullableBooleanConverter : BaseTypeConverter<bool?>
    {
        public override bool? ConvertFromString(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return default(bool?);
            }

            return bool.Parse(value as string);
        }

        public override string ConvertToString(object value)
        {
            if (value == null)
            {
                return null;
            }
            return value.ToString();
        }
    }
}
